<?php
class MLBlog extends MModule {
    protected static $_version = '0.01';
    private static $_name      = 'ml-blog';
    
    /**
     * Configure the ActiveRecord library
     */
    public static function initModel(){
        ActiveRecord\Config::initialize(function($cfg){
            $cfg->set_model_directory(__DIR__.DS.'models');
            $cfg->set_connections(Mandrill::getApp()->dbConnection);
            $cfg->set_default_connection('mandrill');
        });
    }

    /**
     * Initialize the menu
     */
    public static function initMenu() {
        $m = new MMenu();
        $menu = $m->renderAllMenus(self::$_name);
        self::assign('menu', $menu);
    }

    /**
     * Initialize categories
     */
    public static function initCategories(){
        $categories = Category::all();
        self::assign('categories', $categories);
    }

    /**
     * Initialize links
     */
    public static function initLinks(){
        $links = Link::all();
        self::assign('links', $links);
    }

    /**
     * Initialize the footer
     */
    public static function initFooter() {
        self::assign('footer_content', Mandrill::poweredBy());
//        self::assign('footer_content', MSetting::getInstance()->getSetting('footer_content'));
    }

    public static function initAdminJavascript() {
        MPackage::import('jquery-ui');
        MPackage::import('mandrill-widget');
        MPackage::import('jquery-form');
        MPackage::import('jquery-editor');
    }

    public static function initAdminCss(){
        MPublisher::publish(__DIR__.DS.'admin'.DS.'css'.DS.'ml.blog.admin.css', true);
    }

    public static $classes = array(
        'HomeController'=>'/controllers/home.php',
        'PostController'=>'/controllers/post.php',
        'Category'=>'/models/category.php',
        'Comment'=>'/models/comment.php',
        'Link'=>'/models/link.php',
        'Post'=>'/models/post.php',
        'PostCategory'=>'/models/post_category.php',
        'PostStatus'=>'/models/post_status.php',
        'PostTag'=>'/models/post_tag.php',
        'Profile'=>'/models/profile.php',
        'User'=>'/models/user.php',
        'Tag'=>'/models/tag.php',
    );
    
    public static $adminClasses = array(
        'AdminHomeController'=>'/admin/controllers/home.php',
        'AdminPostController'=>'/admin/controllers/post.php',
        'PostCreateForm'=>'/admin/forms/postCreateForm.php',
        'QuickPublishForm'=>'/admin/forms/quickPublishForm.php',
        'Category'=>'/models/category.php',
        'Comment'=>'/models/comment.php',
        'Link'=>'/models/link.php',
        'Post'=>'/models/post.php',
        'PostCategory'=>'/models/post_category.php',
        'PostStatus'=>'/models/post_status.php',
        'PostTag'=>'/models/post_tag.php',
        'Profile'=>'/models/profile.php',
        'User'=>'/models/user.php',
        'Tag'=>'/models/tag.php',
    );

}
?>